package com.javaspeak.interviewquestions.multipleanalyser;

import org.junit.Test;
import org.junit.internal.TextListener;
import org.junit.runner.JUnitCore;

import com.javaspeak.interviewquestions.multipleanalyser.MultipleAnalyzer;

import static org.junit.Assert.assertEquals;

/**
 * Unit Test to test MultipleAnalyzer
 * 
 * @author John Dickerson
 */
public class MultipleAnalyzerTest {

	@Test
	public void testPrintNumbers(){
		
		MultipleAnalyzer.printNumbersAndMultipleStrings();
		
		String[] cache = MultipleAnalyzer.getCache();
		
		for ( int i=1; i<101; i++ ){
			
			if ( i%3 == 0 && i%5 == 0 ){
				
				assertEquals( cache[ i ], "Peek a Boo" );
			}
			else if ( i%3 == 0 ){
				
				assertEquals( cache[ i ], "Peek" );
			}
			else if ( i%5 == 0 ){
				
				assertEquals( cache[ i ], "Boo" );
			}
			else {
				
				assertEquals( cache[ i ], i + "" );
			}
		}
	}
	
	
	public static void main( String args[] ){
		
		JUnitCore junitCore = new JUnitCore();
		junitCore.addListener( new TextListener( System.out ) );
		junitCore.run( MultipleAnalyzerTest.class );		
	}
}
